package com.bandroid.demo.view;


import android.app.Fragment;
import android.content.Intent;
import android.content.Loader;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;


import com.bandroid.demo.R;
import com.bandroid.demo.base.MyActivity;
import com.bandroid.demo.base.MyApplication;
import com.base.balibrary.base.BaseActivity;
import com.base.balibrary.ioc.BaseContentView;
import com.base.balibrary.ioc.BaseOnClick;
import com.base.balibrary.ioc.BaseViewInject;
import com.bandroid.demo.test.Test;
import com.base.balibrary.utils.LoadImage.DisplayImg;
import com.base.balibrary.utils.http.HttpGetOrPost;

import java.io.UnsupportedEncodingException;
import java.lang.reflect.Constructor;

import IPlugin.IPlugin;
import dalvik.system.DexClassLoader;

/**
 * BAndroid
 * Created by YichenZ on 2015/7/23 16:42.
 */
@BaseContentView(R.layout.activity_main)
public class MainActivity extends MyActivity {
    @BaseViewInject(R.id.okBtn)
    Button okBtn;
    @BaseViewInject(R.id.dialogBtn)
    Button dialogBtn;
    @BaseViewInject(R.id.listViewBtn)
    Button listViewBtn;
    @BaseViewInject(R.id.testIv)
    ImageView testIv;
    @BaseViewInject(R.id.webBtn)
    Button webBtn;
    @BaseViewInject(R.id.loginVideo)
    Button loginVideo;
    @BaseViewInject(R.id.TabViewBtn)
    Button TabViewBtn;
    @BaseViewInject(R.id.menuBtn)
    Button menuBtn;
    @BaseViewInject(R.id.plugin_btn)
    Button pluginBtn;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        okBtn.setText("testOkBtn");
        initData();

    }

    private void initData() {
        DisplayImg.getInstance().displayImg(this, testIv, "http://pic.nipic.com/2007-11-09/2007119122519868_2.jpg");

        mThreadPool.execute(mRunnable);

    }

    Runnable mRunnable = new Runnable() {
        @Override
        public void run() {
            try {
                mApplication.logMessage(HttpGetOrPost.getHttpPostLin("http://api.t.5zou.net/verify/getTheBestServer", null));
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
        }
    };

    @BaseOnClick({R.id.okBtn, R.id.dialogBtn, R.id.listViewBtn, R.id.webBtn, R.id.loginVideo, R.id.TabViewBtn, R.id.menuBtn
    ,R.id.plugin_btn})
    @Override
    public void onClick(View view) {
        super.onClick(view);
        switch (view.getId()) {
            case R.id.okBtn: {
                strActivity(this, Test.class, false, false);
                break;
            }
            case R.id.dialogBtn: {
                strActivity(this, CustomDialogActivity.class, false, false);
                break;
            }
            case R.id.listViewBtn: {
                strActivity(this, ListActivity.class, false, false);
                break;
            }
            case R.id.webBtn: {
                strActivity(this, WebActivity.class, false, false);
                break;
            }
            case R.id.loginVideo: {
                strActivity(this, LoginVideoActivity.class, false, false);
                break;
            }
            case R.id.TabViewBtn: {
//                strActivity(this,);
                break;
            }
            case R.id.menuBtn: {
                strActivity(this, MenuActivity.class, false, false);
                break;
            }
            case R.id.plugin_btn:{
                strActivity(this,PluginActivity.class);
                break;
            }
        }

    }

}
